home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / mus / play / mpegagui.lha / mpegagui / MPEGA.gc < prev    next >
Encoding:
Gui4CLI script  |  1997-08-20  |  23.3 KB  |  992 lines

  1. G4C
  2.  
  3. ; Hi there!
  4. ; This is a Gui4CLI Script. Once runned, it pops up a GUI (Graphical
  5. ; User Interface, in short: a window with buttons) which can be used
  6. ; as a frontend for MPEGA.
  7. ; This script was developed for Gui4CLI version 3 :
  8. ; > Author   : dck@prometheus.hol.gr (D. Keletsekis)
  9. ; > Type     : Dev/Gui
  10. ; > Version  : 3.0
  11. ; > Requires : WB 2.04 or higher
  12. ; This GUI was developed for MPEGA version 2.9 :
  13. ; > MPEGA V2.9 [68020/30] (C)1995-1997 Stéphane TAVENARD
  14. ; > Release date: May 29 1997 (68020/30)
  15. ; > Email: tavenard@xiii.univ-angers.fr
  16. ; Gui4CLI can be downloaded from AmiNet from the directory dev/gui.
  17. ; MPEGA can be downloaded from AmiNet from the directory mus/play.
  18. ; If you don't like this script you are allowed to change it yourself.
  19. ; If you do so, I would like you to E-mail me your new version.
  20. ; If you change this script and redistribute it, you are not allowed
  21. ; to erase my copyright notice. Feel free to add your own notice.
  22. ; This GUI was developed on a screen resolution of 640*495 pixels.
  23. ; I've tested it on a PAL 640*256 screen and didn't like the window
  24. ; sizes. If you want to run it on a 640*256 screen, you can change
  25. ; the default window sizes. How to do that is perfectly described in
  26. ; the Gui4CLI documentation (Gui4CLI.guide) which comes with the
  27. ; Gui4CLI package. I recommend reading the 'Important Topics! /
  28. ; Window Shortcuts' and the 'COMMANDS / WinBig' sections for that.
  29. ; You also might want to change the default paths the GUI uses.
  30. ; They are at lines 61 and 62 of this file.
  31. ; There are some bugs in this GUI due to the nature of it: it uses
  32. ; the OS multitasking. If you want, you can crash it. Just hit some
  33. ; different buttons with a very short interval. If you think it's lame
  34. ; for that, go buy a faster Miggy...
  35. ; Copyright 1997 M. van Dillen
  36. ; E-mail: 1011071@ibk.fnt.hvu.nl
  37.  
  38.  
  39. WINBIG 1024 11 380 235 'MPEGA GUI v1.0 by Kozmic'
  40. WinType 11110001
  41. WinSmall -1 -1 365 190
  42.  
  43. ICON 180 20 :MPEGA.gc
  44. gadid 8
  45.  
  46. xOnLoad
  47. version = 'MPEGA GUI v1.0'
  48. Extract MPEGA.gc GuiPath KozPath
  49. Exe = 'dh1:music/mpega/mpega'
  50. GoSub MPEGA.gc CheckExe
  51. defaultpath = 'MP3:'
  52. playlistpath = 'MP3:Playlists'
  53. header = '@MP3PLAYLIST@'
  54. stilte = 0
  55. warning = 1
  56. stilte = 1
  57. playing = 0
  58. files = 0
  59. inf = 0
  60. IF $inf = 1
  61.    SetGad MPEGA.gc 8 hide
  62. ELSE
  63.    SetGad MPEGA.gc 10 hide    ;box
  64.    SetGad MPEGA.gc 11 hide    ;text
  65.    SetGad MPEGA.gc 12 hide    ;text
  66.    SetGad MPEGA.gc 13 hide    ;text
  67.    SetGad MPEGA.gc 14 hide    ;text
  68.    SetGad MPEGA.gc 15 hide    ;text
  69.    SetGad MPEGA.gc 16 hide    ;text
  70. ENDIF
  71. JoinFile $KozPath 'MPEGAGUI.options' opfile
  72. IfExists FILE $opfile
  73.    Copy $opfile 'ENV:.MPEGAGUI.options'
  74.    extra = $.MPEGAGUI.options
  75. ENDIF
  76. JoinFile $KozPath 'MP3Info' getinfo
  77.  
  78. priority = 0
  79. prio2 = 1
  80. negprio = 0
  81. offset = 0
  82. volume = 128
  83. buffer = 131
  84. maxfreq = 22000
  85. SetVar mf 'Off'
  86. SetVar wait 'Off'
  87. Update MPEGA.gc 1 0        ; mono
  88. Update MPEGA.gc 2 1        ; freq div 2
  89. Update MPEGA.gc 3 1        ; quality good
  90. SetGad MPEGA.gc 4 OFF        ; AHI Off
  91. SetGad MPEGA.gc 6 OFF        ; buffer disabled
  92. SetGad MPEGA.gc 7 OFF        ; max freq disabled
  93. redraw MPEGA.gc
  94. GuiOpen MPEGA.gc
  95.  
  96. xOnClose
  97. GoSub MPEGA.gc cleanup
  98. GuiQuit Playlist.gc
  99. GuiQuit extra.gc
  100. GuiQuit MPEGA.gc
  101.  
  102.  
  103. ;--- Misc ---
  104.  
  105. xOnKey #13
  106. GoSub MPEGA.gc stop
  107. GoSub MPEGA.gc play
  108.  
  109. xOnKey ' '
  110. GoSub MPEGA.gc stop
  111.  
  112. xOnKey 'l'
  113. GoSub Playlist.gc load
  114. IF $files > 1
  115.    ;Playlist window init en openen
  116.    GuiLoad Playlist.gc
  117.    GuiOpen Playlist.gc
  118. ELSE
  119.    IFEXISTS Window Playlist.gc
  120.       GuiClose Playlist.gc
  121.    ENDIF
  122. ENDIF
  123.  
  124. xOnKey #27
  125. GoSub MPEGA.gc cleanup
  126. GuiQuit Playlist.gc
  127. GuiQuit extra.gc
  128. GuiQuit MPEGA.gc
  129.  
  130. xAppWindow Filenames
  131. ;alle icons verwerken
  132. IF $Filenames > ""
  133.    ;Listview input maken
  134.    files = 0
  135.    CLI 'Echo "" NOLINE > T:MPEGAGUI.temp'
  136.    WHILE $Filenames != ""
  137.       CutVar Filenames CUT WORD 1 eenfile
  138.       APPEND T:MPEGAGUI.temp $eenfile
  139.       IF $files = 0
  140.          Filename = $eenfile
  141.       ENDIF
  142.       CutVar Filenames CUT CHAR 1 space
  143.       IF $Filenames != ""
  144.          APPEND T:MPEGAGUI.temp \n
  145.       ENDIF   
  146.       files == $files + 1
  147.    ENDWHILE
  148.    IF $files > 1
  149.       ;Playlist window init en openen
  150.       GuiLoad Playlist.gc
  151.       LVUse Playlist.gc 1
  152.       LVChange T:MPEGAGUI.temp
  153.       GuiOpen Playlist.gc
  154.    ELSE
  155.       IFEXISTS Window Playlist.gc
  156.          GuiClose Playlist.gc
  157.       ENDIF
  158.    ENDIF
  159.    Update MPEGA.gc 5 'Current file: $Filename'
  160. ENDIF
  161. ;play it!
  162. GoSub MPEGA.gc stop
  163. GoSub MPEGA.gc play
  164.  
  165.  
  166. ;--- Left gadgets ---
  167.  
  168. XCYCLER 88 10 80 18   "_Mode" "mymode"
  169. gadid 1
  170. CStr Mono 0
  171. CStr Stereo 1
  172.  
  173. XCYCLER 88 30 80 18   "Freq _Div" freq
  174. gadid 2
  175. CStr 1 0
  176. CStr 2 1
  177. CStr 4 2
  178.  
  179. XCYCLER 88 50 80 18   "_Quality" "quality"
  180. gadid 3
  181. CStr Worst 0
  182. CStr Good 1
  183. CStr Best 2
  184.  
  185. XTEXTIN 88 74 80 18   "Buffer time" "buffer" "131" 10
  186. gadid 6
  187. IF $buffer = ""
  188.    buffer = "0"
  189.    update MPEGA.gc 9 $buffer
  190. ENDIF
  191. Update MPEGA.gc 5 'Waiting for buffer to be full will now be enabled'
  192.  
  193. XTEXTIN 88 94 80 18   "Max Freq" "maxfreq" "22049" 10
  194. gadid 7
  195. Update MPEGA.gc 5 'Maximum decoding frequency will be $maxfreq Hz'
  196.  
  197. XTEXTIN 88 114 80 18   "Mode ID" "ahimode" "20004" 5
  198. gadid 4
  199. Update MPEGA.gc 5 'AHI will now be enabled'
  200.  
  201. XTEXTIN 88 134 80 18   "Stream start" "offset" "0" 10
  202. gadid 9
  203. IF $offset = ""
  204.    offset = "0"
  205.    update MPEGA.gc 9 $offset
  206. ENDIF
  207. Update MPEGA.gc 5 'Playing will start at offset $offset seconds'
  208.  
  209. XHSLIDER 88 158 80 18   "_Volume" "volume" 0 256 128 "%ld"
  210. IF $volume < 65
  211.    Update MPEGA.gc 5 'Volume will be $volume'
  212. ELSE
  213.    Update MPEGA.gc 5 'Volume will be boosted to $volume'
  214. ENDIF
  215.  
  216.  
  217. ;--- Right gadgets ---
  218.  
  219. TEXT 180 10 190 58 "" 1 BOX
  220. gadid 10
  221.  
  222. TEXT 185 12 100 10 "Title:" 6 NOBOX
  223. gadid 14
  224. TEXT 185 21 100 10 "<not available>" 30 NOBOX
  225. gadid 11
  226. TEXT 185 30 100 10 "Artist / Group:" 15 NOBOX
  227. gadid 15
  228. TEXT 185 39 100 10 "<not available>" 30 NOBOX
  229. gadid 12
  230. TEXT 185 48 100 10 "Album:" 6 NOBOX
  231. gadid 16
  232. TEXT 185 57 100 10 "<not available>" 30 NOBOX
  233. gadid 13
  234.  
  235. XCHECKBOX 200 74 26 18   "_Wait for buffer" "wait" "On" "Off" OFF
  236. GadTitle RIGHT
  237. IF $wait = "On"
  238.    setgad MPEGA.gc 6 ON
  239.    Update MPEGA.gc 5 'Enter seconds of playback buffer'
  240. ELSE
  241.    setgad MPEGA.gc 6 OFF
  242.    Update MPEGA.gc 5 'Waiting for buffer to be full will now be disabled'
  243. ENDIF
  244.  
  245. XCHECKBOX 200 94 26 18   "Ma_x freq" "mf" "On" "Off" OFF
  246. GadTitle RIGHT
  247. IF $mf = "On"
  248.    setgad MPEGA.gc 7 ON
  249.    setgad MPEGA.gc 2 OFF
  250.    Update MPEGA.gc 5 'Enter maximum playback frequency'
  251. ELSE
  252.    setgad MPEGA.gc 7 OFF
  253.    setgad MPEGA.gc 2 ON
  254.    Update MPEGA.gc 5 'Standard playback frequency will be used'
  255. ENDIF
  256.  
  257. XCHECKBOX 200 114 26 18   "_AHI" "ahi" "On" "Off" OFF
  258. GadTitle RIGHT
  259. IF $ahi = "On"
  260.    setgad MPEGA.gc 4 ON
  261.    Update MPEGA.gc 5 'Enter the AHI Audio mode ID in hex'
  262. ELSE
  263.    setgad MPEGA.gc 4 OFF
  264.    Update MPEGA.gc 5 'AHI will now be disabled'
  265. ENDIF
  266.  
  267. XCHECKBOX 200 134 26 18   "Audio f_ilter" "filter" "On" "Off" OFF
  268. GadTitle RIGHT
  269. Update MPEGA.gc 5 'Audio filter will now be $filter'
  270.  
  271. XHSLIDER 266 158 80 18   "P_riority" "priority" -30 30 0 "%ld"
  272. IF $priority < 31
  273.    Update MPEGA.gc 5 'Process priority of MpegA will be $priority'
  274.    negprio = 0
  275. ELSE
  276.    prio2 = 65536
  277.    COUNTER prio2 DEC $priority
  278.    Update MPEGA.gc 5 'Process priority of MpegA will be -$prio2'
  279.    negprio = 1
  280. ENDIF
  281.  
  282.  
  283. ;--- Bottom gadgets ---
  284.  
  285. XBUTTON 5 182 120 20   "Choose _file(s)..."
  286. Set FilePattern #?MP3#?
  287. GoSub MPEGA.gc setwait
  288. ReqFile 10 10 300 256 "Choose MPEG Audio file(s)" MULTI "Filenames" $defaultpath
  289. GoSub MPEGA.gc setresume
  290.  
  291. IF $Filenames > ""
  292.    ;Listview input maken
  293.    files = 0
  294.    CLI 'Echo "" NOLINE > T:MPEGAGUI.temp'
  295.    WHILE $Filenames != ""
  296.       CutVar Filenames CUT WORD 1 eenfile
  297.       APPEND T:MPEGAGUI.temp $eenfile
  298.       IF $files = 0
  299.          Filename = $eenfile
  300.       ENDIF
  301.       CutVar Filenames CUT CHAR 1 space
  302.       IF $Filenames != ""
  303.          APPEND T:MPEGAGUI.temp \n
  304.       ENDIF   
  305.       files == $files + 1
  306.    ENDWHILE
  307.    IF $files > 1
  308.       ;Playlist window init en openen
  309.       GuiLoad Playlist.gc
  310.       LVUse Playlist.gc 1
  311.       LVChange T:MPEGAGUI.temp
  312.       GuiOpen Playlist.gc
  313.    ELSE
  314.       IFEXISTS Window Playlist.gc
  315.          GuiClose Playlist.gc
  316.       ENDIF
  317.    ENDIF
  318.    Update MPEGA.gc 5 'Current file: $Filename'
  319. ENDIF
  320.  
  321.  
  322. XBUTTON 130 182 120 20   "_PLAY!"
  323. GoSub MPEGA.gc stop
  324. GoSub MPEGA.gc play
  325.  
  326. XBUTTON 255 182 120 20   "_Stop playing"
  327. GoSub MPEGA.gc stop
  328.  
  329. TEXT 5 210 370 18   "Welcome to Kozmic's MPEGA GUI                              " 60 BOX
  330. gadid 5
  331.  
  332.  
  333.  
  334. ;--- Routines ---
  335.  
  336.  
  337. XROUTINE play
  338.  
  339. stilte = 0
  340.  
  341. ;filter bepalen
  342. IF $filter = "On"
  343.    SetVar fil '1'
  344. ELSE
  345.    SetVar fil '0'
  346. ENDIF
  347.  
  348. ;freq div bepalen
  349. DOCASE $freq
  350.    CASE = 0
  351.       SetVar f '1'
  352.    BREAK
  353.    CASE = 1
  354.       SetVar f '2'
  355.    BREAK
  356.    CASE = 2
  357.       SetVar f '4'
  358.    BREAK
  359. ENDCASE
  360.  
  361. ;neg of pos priority bepalen
  362. SetVar prioarg '-p'
  363. IF $negprio = 1
  364.    AppVar prioarg '-$prio2'
  365. ELSE
  366.    AppVar prioarg '$priority'
  367. ENDIF   
  368.  
  369. ;controleren op een hoge priority
  370. warning = 1
  371. IF $priority > 4
  372. AND $negprio = 0
  373. GoSub MPEGA.gc setwait
  374.    EZReq 'Warning! A high priority may lockup your system!' Continue|Cancel warning
  375. GoSub MPEGA.gc setresume
  376. ENDIF
  377.  
  378. ;mode bepalen
  379. SetVar modearg '-n'            ;geen zooi naar stdout
  380. IF $mymode = 0
  381.    AppVar modearg ' -m'
  382. ENDIF
  383.  
  384. ;waardes converteren naar milliseconden
  385. SetVar offs '-S'
  386. AppVar offs '$offset'
  387. AppVar offs '000'
  388. SetVar buff '-t'
  389. AppVar buff '$buffer'
  390. AppVar buff '000'
  391.  
  392. ;volume, wait en maxfreq
  393. SetVar volwaitmf '-v$volume'
  394. IF $wait = 'On'
  395.    AppVar volwaitmf ' $buff -w'
  396. ENDIF
  397. IF $mf = 'On'
  398.    AppVar volwaitmf ' -F$maxfreq'
  399. ENDIF
  400. IF $extra > ""
  401.    AppVar volwaitmf ' $extra'
  402. ENDIF
  403.  
  404. ;play it!
  405. IF $warning = 1
  406.    IF $inf = 1
  407.       CLI '$getinfo $Filename >ENV:.MPEGAGUI.inf'
  408.    ELSE
  409.       .MPEGAGUI.inf = ""
  410.    ENDIF
  411.    LAUNCH 1 '"$Exe" -d$f -q$quality -f$fil $modearg $volwaitmf $prioarg $offs $Filename >NIL:'
  412.    Update MPEGA.gc 5 'Now playing: $Filename'
  413.    IF $.MPEGAGUI.inf > ""
  414.       infostring = $.MPEGAGUI.inf
  415.       CutVar infostring CUT CHAR 30 eenfile
  416.       update MPEGA.gc 11 $eenfile
  417.       CutVar infostring CUT CHAR 30 eenfile
  418.       update MPEGA.gc 12 $eenfile
  419.       update MPEGA.gc 13 $infostring
  420.    ELSE
  421.       update MPEGA.gc 11 "<not available>"
  422.       update MPEGA.gc 12 "<not available>"
  423.       update MPEGA.gc 13 "<not available>"
  424.    ENDIF
  425.    playing == $playing + 1
  426.    nowplaying = $Filename
  427. ELSE
  428.    Update MPEGA.gc 5 'Canceled'        ;cancel in priority warning gekozen
  429. ENDIF
  430.  
  431.  
  432. XOnReturn 1
  433. IF $playing = 1
  434. AND $stilte = 0
  435.    IF $files > 1
  436.       LVUse Playlist.gc 1
  437.       top == $files - 1
  438.       IF $$lv.rec = $nowplaying        ;geen andere manually chosen
  439.          IF $$lv.line != $top        ;niet? -> next
  440.             LVGo next
  441.          ELSE
  442.             LVGo first
  443.          ENDIF
  444.       ENDIF
  445.       Filename = $$lv.rec        ;else choose users wish
  446.       GoSub MPEGA.gc play
  447.    ELSE
  448.       Update MPEGA.gc 5 'Finished'
  449.    ENDIF
  450. ENDIF
  451. playing == $playing - 1
  452.  
  453.  
  454. xOnFail
  455. playing = 0
  456. stilte = 1
  457. Update MPEGA.gc 5 'External error!'
  458.  
  459.  
  460. XROUTINE stop
  461. IF $playing > 0
  462.    CLI 'break `status com "$Exe"` >NIL:'
  463.    Update MPEGA.gc 5 'Playing stopped'
  464.    stilte = 1
  465. ENDIF
  466.  
  467.  
  468. XROUTINE setwait
  469. GuiWindow MPEGA.gc WAIT
  470. GuiWindow Playlist.gc WAIT
  471. GuiWindow extra.gc WAIT
  472.  
  473.  
  474. XROUTINE setresume
  475. GuiWindow MPEGA.gc RESUME
  476. GuiWindow Playlist.gc RESUME
  477. GuiWindow extra.gc RESUME
  478.  
  479.  
  480. XROUTINE cleanup
  481. Delete T:MPEGAGUI.temp
  482. Delete ENV:.MPEGAGUI.options
  483. Delete ENV:.MPEGAGUI.inf
  484. Delete ENV:.MPEGAGUI.header
  485. Delete ENV:.MPEGAGUI.filesize
  486. IF $playing > 0
  487.    EZReq 'MPEGA is still running. What shall I do with it?' "Stop it!|Keep it running" stopit
  488.    IF $stopit = 1
  489.       GoSub MPEGA.gc stop
  490.    ENDIF
  491. ENDIF
  492.  
  493.  
  494. XROUTINE about
  495. EZReq "$version \n\nMPEGAGUI is a frontend for MPEGA,\nan MPEG Audio layer 1, 2 and 3 player.\n\nIt is a Gui4CLI script so you need to get\nthe Gui4CLI package e.g. from AmiNet to get\nit running, but you already knew that unless\nyou're reading this script instead of\nrunning it..\n\nIf you don't like it, change it yourself :-)\n\nCopyright 1997 M. van Dillen (1011071@ibk.fnt.hvu.nl)" Cool! egwel
  496.  
  497.  
  498. XROUTINE CheckExe
  499. IfExists FILE $Exe
  500.    ; bug
  501. Else
  502.    EZReq "MPEGA Executable not found!\nCurrent definition is:\n'$Exe' \n\nYou have to change the 'Exe' definition in the\nfile 'MPEGA.gc' on line number 59\nwith a texteditor.\n\nFor now, you can locate the executable yourself\n(version 2.9+), edit the file 'MPEGA.gc',\nor exit this marvelous GUI.." "Locate MPEGA|Ed MPEGA.gc|Exit" locate
  503.    DOCASE $locate
  504.    CASE = 1
  505.       Set FilePattern #?MPEGA#?
  506.       ReqFile 10 10 300 256 "Locate the MPEGA Executable" LOAD "Exe" $defaultpath
  507.       BREAK
  508.    CASE = 2
  509.       JoinFile $KozPath 'MPEGA.gc' ThisSux
  510.       CLI 'C:Ed $ThisSux'
  511.       EZReq "Please restart MPEGA.gc now." "Exit" egwel
  512.       GuiQuit Playlist.gc
  513.       GuiQuit extra.gc
  514.       GuiQuit MPEGA.gc
  515.       Stop
  516.       BREAK
  517.    CASE = 0
  518.       GuiQuit Playlist.gc
  519.       GuiQuit extra.gc
  520.       GuiQuit MPEGA.gc
  521.       Stop
  522.       BREAK
  523.    ENDCASE
  524. EndIf
  525.  
  526.  
  527. ;--- Menu's ---
  528.  
  529. xMenu Project "Load Playlist..." "" "L"
  530. GoSub Playlist.gc load
  531. IF $files > 1
  532.    ;Playlist window init en openen
  533.    GuiLoad Playlist.gc
  534.    GuiOpen Playlist.gc
  535. ELSE
  536.    IFEXISTS Window Playlist.gc
  537.       GuiClose Playlist.gc
  538.    ENDIF
  539. ENDIF
  540.  
  541. xMenu Project Play "" "P"
  542. GoSub MPEGA.gc stop
  543. GoSub MPEGA.gc play
  544.  
  545. xMenu Project Stop "" "S"
  546. stilte = 1
  547. GoSub MPEGA.gc stop
  548.  
  549. xMenu Project "" "" ""
  550.  
  551. xMenu Project "About" "#:MPEGA.gc" ""
  552. GoSub MPEGA.gc about
  553.  
  554. xMenu Project " " "" ""
  555.  
  556. xMenu Project Quit "" "Q"
  557. GuiClose MPEGA.gc
  558.  
  559. xMenu Windows "Extra options..." "" "E"
  560. Update extra.gc 1 $extra
  561. GuiOpen extra.gc
  562.  
  563. xMenu Windows "Toggle Playlist" "" ""
  564. IFEXISTS Window Playlist.gc
  565.    GuiClose Playlist.gc
  566. ELSE
  567.    GuiOpen Playlist.gc
  568. ENDIF
  569.  
  570. xMenu Misc "Toggle MP3 Info" "" "I"
  571. IF $inf = 1
  572.    inf = 0
  573.    SetGad MPEGA.gc 8 show    ;logo
  574.    SetGad MPEGA.gc 10 hide    ;box
  575.    SetGad MPEGA.gc 11 hide    ;text
  576.    SetGad MPEGA.gc 12 hide    ;text
  577.    SetGad MPEGA.gc 13 hide    ;text
  578.    SetGad MPEGA.gc 14 hide    ;text
  579.    SetGad MPEGA.gc 15 hide    ;text
  580.    SetGad MPEGA.gc 16 hide    ;text
  581.    Update MPEGA.gc 5 'No info will be searched'
  582. ELSE
  583.    inf = 1
  584.    SetGad MPEGA.gc 8 hide    ;logo
  585.    SetGad MPEGA.gc 10 show    ;box
  586.    SetGad MPEGA.gc 11 show    ;text
  587.    SetGad MPEGA.gc 12 show    ;text
  588.    SetGad MPEGA.gc 13 show    ;text
  589.    SetGad MPEGA.gc 14 show    ;text
  590.    SetGad MPEGA.gc 15 show    ;text
  591.    SetGad MPEGA.gc 16 show    ;text
  592.    Update MPEGA.gc 5 'Songinfo will be searched at playtime'
  593. ENDIF
  594. redraw MPEGA.gc
  595.  
  596. xMenu Misc "Show status" "" ""
  597. IF $playing > 0
  598.    CLI 'List lformat %l $nowplaying > ENV:.MPEGAGUI.filesize'
  599.    thissux = 'Now playing: $nowplaying ('
  600.    AppVar thissux $.MPEGAGUI.filesize
  601.    AppVar thissux ')'
  602.    ; This sucks. You can't say 'blahblah ($variable)' because it then searches
  603.    ; for the var  variable)  which doesn't exist.
  604.    Update MPEGA.gc 5 $thissux
  605.    Delete ENV:.MPEGAGUI.filesize
  606. ELSE
  607.    Update MPEGA.gc 5 'Idle'
  608. ENDIF
  609.  
  610. ;================================================================================================
  611. ;================================================================================================
  612. ;================================================================================================
  613.  
  614. NEWFILE Playlist.gc
  615.  
  616. WINBIG 1024 267 380 100 'MPEGA GUI Playlist'
  617. WinType 11110001
  618. WinSmall -1 -1 158 100
  619.  
  620. xAppWindow Filenames
  621. IF $Filenames > ""
  622.    ;Listview input maken
  623.    IfExists FILE T:MPEGAGUI.temp
  624.       CLI 'Echo "" >> T:MPEGAGUI.temp'            ;return plakken
  625.    ELSE
  626.       CLI 'Echo "" NOLINE > T:MPEGAGUI.temp'        ;file aanmaken
  627.       files = 0
  628.    ENDIF
  629.    WHILE $Filenames != ""
  630.       CutVar Filenames CUT WORD 1 eenfile
  631.       APPEND T:MPEGAGUI.temp $eenfile
  632.       IF $files = 0
  633.          Filename = $eenfile
  634.       ENDIF
  635.       CutVar Filenames CUT CHAR 1 space
  636.       IF $Filenames != ""
  637.          APPEND T:MPEGAGUI.temp \n
  638.       ENDIF   
  639.       files == $files + 1
  640.    ENDWHILE
  641.    ;Playlist window init en openen
  642.    GuiLoad Playlist.gc
  643.    LVUse Playlist.gc 1
  644.    LVChange T:MPEGAGUI.temp
  645.    GuiOpen Playlist.gc
  646.    Update MPEGA.gc 5 'Current file: $Filename'
  647. ENDIF
  648.  
  649.  
  650. XListView 0 26 -1 74 "" LVFilename T:MPEGAGUI.temp 0 TXT
  651. gadid 1
  652. IF $$lv.rec != 'No Data'
  653.    Filename = $LVFilename
  654.    IF $playing > 0
  655.       Update MPEGA.gc 5 'Next file: $Filename'
  656.    ELSE
  657.       Update MPEGA.gc 5 'Current file: $Filename'
  658.    ENDIF
  659. ENDIF
  660.  
  661. XButton 0 0 76 13 "I"
  662. GadFont gc.font 12 000
  663. LVUse Playlist.gc 1
  664. LVGo first
  665. Filename = $$lv.rec
  666. Update MPEGA.gc 5 'Current file: $Filename'
  667.  
  668. XButton 76 0 76 13 "G"
  669. GadFont gc.font 12 000
  670. LVUse Playlist.gc 1
  671. IF $$lv.line != 0
  672.    LVGo prev
  673.    Filename = $$lv.rec
  674.    Update MPEGA.gc 5 'Current file: $Filename'
  675. ENDIF
  676. GoSub MPEGA.gc stop
  677. GoSub MPEGA.gc play
  678.  
  679. XButton 152 0 76 13 "Sh_uffle"
  680. LVUse Playlist.gc 1
  681. tel = $files
  682. JoinFile $KozPath 'Random' copyarg
  683. Copy $copyarg T:
  684. WHILE $tel > 0
  685.    CLI 'T:Random $tel > env:.MPEGAGUI.random'
  686.    LVGo #$.MPEGAGUI.random
  687.    vorige = $$lv.line
  688.    LVAdd $$lv.rec
  689.    LVGo #$vorige
  690.    LVDel -1
  691.    tel == $tel - 1
  692. ENDWHILE
  693. Delete T:Random
  694. Delete env:.MPEGAGUI.random
  695. LVGo first
  696. Filename = $$lv.rec
  697. Update MPEGA.gc 5 'Current file: $Filename'
  698.  
  699.  
  700. XButton 228 0 76 13 "g"
  701. GadFont gc.font 12 000
  702. LVUse Playlist.gc 1
  703. top == $files - 1
  704. IF $$lv.line != $top
  705.    LVGo next
  706.    Filename = $$lv.rec
  707.    Update MPEGA.gc 5 'Current file: $Filename'
  708. ENDIF
  709. GoSub MPEGA.gc stop
  710. GoSub MPEGA.gc play
  711.  
  712. XButton 304 0 76 13 "i"
  713. GadFont gc.font 12 000
  714. LVUse Playlist.gc 1
  715. LVGo last
  716. Filename = $$lv.rec
  717. Update MPEGA.gc 5 'Current file: $Filename'
  718.  
  719.  
  720. ;--- 2e regel
  721.  
  722. XButton 0 13 76 13 "_Save"
  723. Set FilePattern #?
  724. GoSub MPEGA.gc setwait
  725. playlistfile = ""
  726. ReqFile 10 10 300 256 "Save Playlist to.." SAVE "playlistfile" $playlistpath
  727. GoSub MPEGA.gc setresume
  728. IF $playlistfile > ""
  729.    IfExists FILE $playlistfile
  730.       EZReq "The file '$playlistfile' already exists!" Replace|Cancel replace
  731.       IF $replace = 1
  732.          CLI 'Echo $header > T:MPEGAGUI.header'
  733.          LVSave T:MPEGAGUI.temp
  734.          CLI 'Type T:MPEGAGUI.header T:MPEGAGUI.temp > $playlistfile'
  735.       ENDIF
  736.    ELSE
  737.       CLI 'Echo $header > T:MPEGAGUI.header'
  738.       LVSave T:MPEGAGUI.temp
  739.       CLI 'Type T:MPEGAGUI.header T:MPEGAGUI.temp > $playlistfile'
  740.    ENDIF
  741. ENDIF
  742.  
  743. XButton 76 13 76 13 "_Load"
  744. GoSub Playlist.gc load
  745.  
  746. XButton 152 13 76 13 "_Add"
  747. Set FilePattern #?MP3#?
  748. GoSub MPEGA.gc setwait
  749. ReqFile 10 10 300 256 "Choose MPEG Audio file(s)" MULTI "Filenames" $defaultpath
  750. GoSub MPEGA.gc setresume
  751. IF $Filenames > ""
  752.    ;Listview input maken
  753.    IfExists FILE T:MPEGAGUI.temp
  754.       CLI 'Echo "" >> T:MPEGAGUI.temp'            ;return plakken
  755.    ELSE
  756.       CLI 'Echo "" NOLINE > T:MPEGAGUI.temp'        ;anders de file aanmaken
  757.       files = 0
  758.    ENDIF
  759.    WHILE $Filenames != ""
  760.       CutVar Filenames CUT WORD 1 eenfile
  761.       APPEND T:MPEGAGUI.temp $eenfile
  762.       IF $files = 0
  763.          Filename = $eenfile
  764.       ENDIF
  765.       CutVar Filenames CUT CHAR 1 space
  766.       IF $Filenames != ""
  767.          APPEND T:MPEGAGUI.temp \n
  768.       ENDIF   
  769.       files == $files + 1
  770.    ENDWHILE
  771.    IF $files > 1
  772.       ;Playlist window init en openen
  773.       GuiLoad Playlist.gc
  774.       LVUse Playlist.gc 1
  775.       LVChange T:MPEGAGUI.temp
  776.       GuiOpen Playlist.gc
  777.    ELSE
  778.       IFEXISTS Window Playlist.gc
  779.          GuiClose Playlist.gc
  780.       ENDIF
  781.    ENDIF
  782.    Update MPEGA.gc 5 'Current file: $Filename'
  783. ENDIF
  784.  
  785. XButton 228 13 76 13 "_Del"
  786. LVUse Playlist.gc 1
  787. IF $files > 0
  788.    LVDel -1
  789.    files == $files - 1
  790.    top == $files - 1
  791.    IF $$lv.line != $top
  792.    AND $$lv.line != 0
  793.       LVGo next
  794.    ENDIF
  795.    Filename = $$lv.rec
  796.    Update MPEGA.gc 5 'Current file: $Filename'
  797.    LVSave T:MPEGAGUI.temp
  798. ELSE
  799.    Update MPEGA.gc 5 'And.. that was the last one :-)'
  800. ENDIF
  801.  
  802. XButton 304 13 76 13 "_Clear"
  803. LVUse Playlist.gc 1
  804. LVClear
  805. files = 0
  806. IFEXISTS FILE T:MPEGAGUI.temp
  807.    Delete T:MPEGAGUI.temp
  808. ENDIF
  809.  
  810.  
  811. ;--- Routines ---
  812.  
  813. XROUTINE load
  814. Set FilePattern #?
  815. GoSub MPEGA.gc setwait
  816. ReqFile 10 10 300 256 "Choose a Playlist file" LOAD "playlistfile" $playlistpath
  817. GoSub MPEGA.gc setresume
  818. IF $playlistfile F= $defaultpath
  819. ; bug
  820. ELSE
  821.    IF $playlistfile H= $header
  822.       Copy $playlistfile T:MPEGAGUI.temp
  823.       LVUse Playlist.gc 1
  824.       LVChange T:MPEGAGUI.temp
  825.       ;laatste weghalen als ie leeg is (return achter laatste record)
  826.       LVGo last
  827.       IF $$lv.rec = ""
  828.          LVDel -1
  829.       ENDIF
  830.       ;eerste weghalen (header)
  831.       LVGo first
  832.       LVDel -1
  833.       Filename = $$lv.rec
  834.       Update MPEGA.gc 5 'Current file: $Filename'
  835.       files = $$lv.total
  836.       ;opslaan zonder header en return
  837.       LVSave T:MPEGAGUI.temp
  838.    ELSE
  839.       GoSub MPEGA.gc setwait
  840.       EZReq "This is not an MPEGAGUI Playlist file!" "You're right. sorry.|Oh yes it is!" joke
  841.       IF $joke = 0
  842.          EZReq "No way! :-)" Oki.. joke
  843.       ENDIF
  844.       GoSub MPEGA.gc setresume
  845.    ENDIF
  846. ENDIF
  847.  
  848.  
  849. ;--- Menu's ---
  850.  
  851. xMenu Project "Load Playlist..." "" "L"
  852. GoSub Playlist.gc load
  853. IF $files > 1
  854.    ;Playlist window init en openen
  855.    GuiLoad Playlist.gc
  856.    GuiOpen Playlist.gc
  857. ELSE
  858.    IFEXISTS Window Playlist.gc
  859.       GuiClose Playlist.gc
  860.    ENDIF
  861. ENDIF
  862.  
  863. xMenu Project Play "" "P"
  864. GoSub MPEGA.gc stop
  865. GoSub MPEGA.gc play
  866.  
  867. xMenu Project Stop "" "S"
  868. stilte = 1
  869. GoSub MPEGA.gc stop
  870.  
  871. xMenu Project "" "" ""
  872.  
  873. xMenu Project "About" "#:MPEGA.gc" ""
  874. GoSub MPEGA.gc about
  875.  
  876. xMenu Project " " "" ""
  877.  
  878. xMenu Project Quit "" "Q"
  879. GuiClose MPEGA.gc
  880.  
  881. xMenu Windows "Extra options..." "" "E"
  882. Update extra.gc 1 $extra
  883. GuiOpen extra.gc
  884.  
  885. xMenu Windows "Toggle Playlist" "" ""
  886. GuiClose Playlist.gc
  887.  
  888. xMenu Misc "Toggle MP3 Info" "" "I"
  889. IF $inf = 1
  890.    inf = 0
  891.    SetGad MPEGA.gc 8 show    ;logo
  892.    SetGad MPEGA.gc 10 hide    ;box
  893.    SetGad MPEGA.gc 11 hide    ;text
  894.    SetGad MPEGA.gc 12 hide    ;text
  895.    SetGad MPEGA.gc 13 hide    ;text
  896.    SetGad MPEGA.gc 14 hide    ;text
  897.    SetGad MPEGA.gc 15 hide    ;text
  898.    SetGad MPEGA.gc 16 hide    ;text
  899.    Update MPEGA.gc 5 'No info will be searched'
  900. ELSE
  901.    inf = 1
  902.    SetGad MPEGA.gc 8 hide    ;logo
  903.    SetGad MPEGA.gc 10 show    ;box
  904.    SetGad MPEGA.gc 11 show    ;text
  905.    SetGad MPEGA.gc 12 show    ;text
  906.    SetGad MPEGA.gc 13 show    ;text
  907.    SetGad MPEGA.gc 14 show    ;text
  908.    SetGad MPEGA.gc 15 show    ;text
  909.    SetGad MPEGA.gc 16 show    ;text
  910.    Update MPEGA.gc 5 'Songinfo will be searched at playtime'
  911. ENDIF
  912. redraw MPEGA.gc
  913.  
  914. xMenu Misc "Show status" "" ""
  915. IF $playing > 0
  916.    CLI 'List lformat %l $nowplaying > ENV:.MPEGAGUI.filesize'
  917.    thissux = 'Now playing: $nowplaying ('
  918.    AppVar thissux $.MPEGAGUI.filesize
  919.    AppVar thissux ')'
  920.    ; This sucks. You can't say 'blahblah ($variable)' because it then searches
  921.    ; for the var  variable)  which doesn't exist.
  922.    Update MPEGA.gc 5 $thissux
  923.    Delete ENV:.MPEGAGUI.filesize
  924. ELSE
  925.    Update MPEGA.gc 5 'Idle'
  926. ENDIF
  927.  
  928. ;================================================================================================
  929. ;================================================================================================
  930. ;================================================================================================
  931.  
  932. NEWFILE extra.gc
  933.  
  934. WINBIG -1 -1 380 50 'MPEGA Extra commandline options'
  935. WinType 11010000
  936.  
  937. xOnKey #27
  938. extra = $.MPEGAGUI.options
  939. Update MPEGA.gc 5 'Extra cmdline options not changed'
  940. GuiClose extra.gc
  941.  
  942. XTEXTIN 5 5 370 18 "" "extra" "" 800
  943. gadid 1
  944.  
  945. xButton 14 28 70 18 "_Save"
  946. .MPEGAGUI.options = $extra
  947. Copy ENV:.MPEGAGUI.options $opfile
  948. Update MPEGA.gc 5 'Extra cmdline options saved: $extra'
  949. GuiClose extra.gc
  950.  
  951. xButton 106 28 70 18 "_Use"
  952. Update MPEGA.gc 5 'Extra cmdline options set: $extra'
  953. GuiClose extra.gc
  954.  
  955. xButton 198 28 70 18 "_Restore"
  956. extra = $.MPEGAGUI.options
  957. Update extra.gc 1 $extra
  958.  
  959. xButton 291 28 70 18 "_Cancel"
  960. extra = $.MPEGAGUI.options
  961. Update MPEGA.gc 5 'Extra cmdline options not changed'
  962. GuiClose extra.gc
  963.  
  964. xMenu Project Save "" ""
  965. .MPEGAGUI.options = $extra
  966. Copy ENV:.MPEGAGUI.options $opfile
  967. Update MPEGA.gc 5 'Extra cmdline options saved: $extra'
  968. GuiClose extra.gc
  969.  
  970. xMenu Project Use "" ""
  971. Update MPEGA.gc 5 'Extra cmdline options set: $extra'
  972. GuiClose extra.gc
  973.  
  974. xMenu Project Restore "" ""
  975. extra = $.MPEGAGUI.options
  976. Update extra.gc 1 $extra
  977.  
  978. xMenu Project Cancel "" ""
  979. extra = $.MPEGAGUI.options
  980. Update MPEGA.gc 5 'Extra cmdline options not changed'
  981. GuiClose extra.gc
  982.